package com.qire.manhua.view;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;

import com.qire.common.basic.ObjectUtil;

public class CanListenRoundedImageView extends  RoundedImageView {

    private OnUpdateDrawableAttrsListener listener;

    public CanListenRoundedImageView(Context context) {
        super(context);
    }

    public CanListenRoundedImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CanListenRoundedImageView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public void setOnUpdateDrawableAttrsListener(OnUpdateDrawableAttrsListener listener) {
        this.listener = listener;
    }

    @Override
    protected void onUpdateDrawableAttrs() {
        if(ObjectUtil.nonNull(listener)) {
            listener.onUpdateDrawableAttrs(getDrawable());
        }
    }

    public interface OnUpdateDrawableAttrsListener {
        void onUpdateDrawableAttrs(Drawable drawable);
    }

}
